extends CanvasLayer


func _ready():
	# 从池中获取3个随机科技
	var races = RaceManager.get_random_races(3)
	
	# 初始化UI（根据新结构调整节点路径）
	for i in 3:
		# 更新路径到新的容器结构
		var option_container = $Panel/OptionsGrid.get_child(i)
		var race = GameData.race_data.get(races[i])
		
		# 根据实际节点结构调整子节点路径（添加MarginContainer和VBoxContainer）
		var panel = option_container.get_node("MarginContainer/VBoxContainer")
		panel.get_node("Icon").texture = load(race.get("icon_path", ""))
		panel.get_node("Name").text = tr(race.get("name", ""))
		panel.get_node("Description").text = tr(race.get("description", ""))
		panel.get_node("SelectBtn").pressed.connect(_on_race_selected.bind(race))

func _on_race_selected(race: Dictionary):
	GameManager.set_race(race)
	GameManager.save_game()
	get_tree().change_scene_to_file("res://game/01_scenes/interface/army_deployment/army_deployment.tscn")
